import FileConfig from './file-config.js'

const request2 = {}
const headers = {}
/*
 *url:接口地址
 * method:请求方式
 * data:参数
 * power:1 formdata传参 2.url传参
 */
request2.globalRequest = (url, method, data, power) => {
	/*
	 *
	 * 1 :application/json 2:application/x-www-form-urlencoded
	 */
	switch (power) {
		case 1:
			headers['content-type'] = 'application/json';
			break;
		case 2:
			headers['content-type'] = 'application/x-www-form-urlencoded';
			break;
		default:
			headers['content-type'] = 'text/plain';
			break;
	}

	return uni.request({
		url: FileConfig + url,
		method,
		data: data,
		dataType: 'json',
		header: headers
	});
}

export default request2
